// 应用常量
export const APP_NAME = '微博爬虫客户端'
export const APP_VERSION = '1.0.0'

// 窗口配置
export const MAIN_WINDOW_CONFIG = {
  width: 1600,
  height: 1000,
  minWidth: 1200,
  minHeight: 800
}

export const LOGIN_WINDOW_CONFIG = {
  width: 800,
  height: 600,
  minWidth: 600,
  minHeight: 400
}

// 微博相关常量
export const WEIBO_URLS = {
  LOGIN: 'https://weibo.com/login.php',
  HOME: 'https://weibo.com',
  SEARCH: 'https://s.weibo.com/weibo'
}

// 数据库配置
export const DATABASE_CONFIG = {
  filename: 'weibo-scraper.db',
  options: {
    verbose: console.log
  }
}

// 默认应用配置
export const DEFAULT_APP_CONFIG = {
  crawler: {
    maxConcurrency: 3,
    requestDelay: 2000,
    retryAttempts: 3,
    timeout: 30000,
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
    enableJavaScript: true,
    enableImages: false
  },
  proxy: {
    enabled: false,
    rotationInterval: 300000, // 5分钟
    healthCheckInterval: 60000, // 1分钟
    servers: []
  },
  storage: {
    dataPath: './data',
    maxFileSize: 100 * 1024 * 1024, // 100MB
    retentionDays: 30,
    compressionEnabled: true,
    backupEnabled: false,
    backupInterval: 24 // 24小时
  },
  logging: {
    level: (process.env.NODE_ENV === 'development' ? 'debug' : 'info') as 'debug' | 'info',
    maxFiles: 5,
    maxSize: '10m',
    enableConsole: true,
    enableFile: true,
    logPath: './logs'
  },
  ui: {
    theme: 'auto' as const,
    language: 'zh-CN' as const,
    autoSave: true
  },
  rabbitmq: {
    host: '43.240.223.138',
    port: 5672,
    username: 'admin',
    password: 'RabbitMQ2025Secure',
    queues: {
      loginSuccess: 'weibo_login_success',
      userInfo: 'weibo_user_info',
      weiboData: 'weibo_data',
      weiboDetail: 'weibo_detail',
      weiboAccount: 'weibo_account',
      scheduledTask: 'weibo_scheduled_task'
    }
  }
}

// IPC 事件名称
export const IPC_EVENTS = {
  // 登录相关
  LOGIN_START: 'login:start',
  LOGIN_VALIDATE: 'login:validate',
  LOGIN_GET_ACCOUNTS: 'login:get-accounts',
  LOGIN_DELETE_ACCOUNT: 'login:delete-account',
  LOGIN_DELETE_INVALID_ACCOUNTS: 'login:delete-invalid-accounts',

  // 任务相关
  TASK_CREATE: 'task:create',
  TASK_START: 'task:start',
  TASK_STOP: 'task:stop',
  TASK_GET_ALL: 'task:get-all',
  TASK_GET_BY_ID: 'task:get-by-id',
  TASK_GET_LOGS: 'task:get-logs',
  TASK_GET_LOGS_BY_ID: 'task:get-logs-by-id',
  TASK_PROGRESS_UPDATE: 'task:progress-update',
  TASK_LOG_UPDATE: 'task:log-update',
  TASK_STATUS_CHANGE: 'task:status-change',
  TASK_COMPLETION: `task:completion`,
  TASK_ERROR: `task:error`,

  // 配置相关
  CONFIG_GET: 'config:get',
  CONFIG_UPDATE: 'config:update',

  // 数据相关
  DATA_EXPORT: 'data:export',
  DATA_GET_STATS: 'data:get-stats',
  DATA_GET_WEIBO_DATA: 'data:get-weibo-data',
  DATA_GET_ALL_WEIBO_DATA: 'data:get-all-weibo-data',
  DATA_SEARCH_WEIBO: 'data:search-weibo',
  DATA_GET_WEIBO_STATS: 'data:get-weibo-stats',
  DATA_GET_WEIBO_LIST: 'data:get-weibo-list',
  DATA_GET_USER_STATS: 'data:get-user-stats',
  DATA_GET_USER_LIST: 'data:get-user-list',
  DEBUG_USER_DATA: 'debug:user-data',
  UPDATE_USERS_COMPLETE_INFO: 'data:update-users-complete-info',

  // 定时任务相关
  SCHEDULER_CREATE_TASK: 'scheduler:create-task',
  SCHEDULER_UPDATE_TASK: 'scheduler:update-task',
  SCHEDULER_DELETE_TASK: 'scheduler:delete-task',
  SCHEDULER_GET_STATUS: 'scheduler:get-status',
  SCHEDULER_GET_ALL_TASKS: 'scheduler:get-all-tasks',
  SCHEDULER_EXECUTE_NOW: 'scheduler:execute-now',
  SCHEDULER_START: 'scheduler:start',
  SCHEDULER_STOP: 'scheduler:stop',

  // 工作流相关
  WORKFLOW_EXECUTE: 'workflow:execute',
  WORKFLOW_GET_STATS: 'workflow:get-stats',
  WORKFLOW_UPDATE_CONFIG: 'workflow:update-config'
} as const

// 任务状态
export const TASK_STATUS = {
  PENDING: 'pending',
  RUNNING: 'running',
  COMPLETED: 'completed',
  FAILED: 'failed',
  CANCELLED: 'cancelled'
} as const

// 任务类型
export const TASK_TYPES = {
  SEARCH: 'search',
  USER: 'user',
  TRENDING: 'trending',
  COMMENTS: 'comments',
  FOLLOWERS: 'followers'
} as const

// 日志级别
export const LOG_LEVELS = {
  DEBUG: 'debug',
  INFO: 'info',
  WARN: 'warn',
  ERROR: 'error'
} as const

// 导出格式
export const EXPORT_FORMATS = {
  JSON: 'json',
  CSV: 'csv',
  XLSX: 'xlsx'
} as const

// 错误类型
export const ERROR_TYPES = {
  NETWORK_ERROR: 'NETWORK_ERROR',
  AUTH_ERROR: 'AUTH_ERROR',
  VALIDATION_ERROR: 'VALIDATION_ERROR',
  DATABASE_ERROR: 'DATABASE_ERROR',
  FILE_SYSTEM_ERROR: 'FILE_SYSTEM_ERROR',
  UNKNOWN_ERROR: 'UNKNOWN_ERROR'
} as const

// 事件类型
export const EVENT_TYPES = {
  // 任务事件
  TASK_PROGRESS: 'task:progress',
  TASK_LOG: 'task:log',
  TASK_STATUS: 'task:status',
  TASK_CREATED: 'task:created',
  TASK_COMPLETED: 'task:completed',

  // 账号事件
  ACCOUNT_LOGIN: 'account:login',
  ACCOUNT_VALIDATION: 'account:validation',
  ACCOUNT_DELETED: 'account:deleted',

  // 系统事件
  CONFIG_CHANGED: 'config:changed',
  ERROR: 'error',
  NOTIFICATION: 'notification',
  DATA_EXPORT: 'data:export',
  DATA_CLEANUP: 'data:cleanup',
  APP_START: 'app:start',
  APP_SHUTDOWN: 'app:shutdown',

  // 窗口事件
  WINDOW_CREATED: 'window:created',
  WINDOW_CLOSED: 'window:closed'
} as const
